package controller;

import dao.ArticleDao;
import entity.Article;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/article/delete")
public class ArticleDeleteServlet extends HttpServlet {
    ArticleDao articleDao = new ArticleDao();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //获取到要删除的文章id
        String id = request.getParameter("id");
        //调用dao层的代码进行文章伪删除status=1
        int total = articleDao.deleteArticleById(id);
        //删除成功调转/main
        if (total > 0) {
            response.sendRedirect("/main");
        } else {
            //删除失败跳转失败页面

        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
